# core/config_loader.py

import os
import yaml


def load_config(file='config.yml'):
    # 获取当前文件所在目录（即 core/ 目录）
    project_dir = os.path.dirname(os.path.dirname(__file__))

    # 拼接 config.yaml 的路径为 core/config/config.yaml
    config_dir = os.path.join(project_dir, "config")
    config_file = os.path.join(config_dir, file)

    with open(config_file, 'r', encoding='utf-8') as f:
        return yaml.safe_load(f)

def env_info(file,project,env):
    """
    读取项目环境信息的配置文件
    """
    config = load_config(file=file)
    return config[project][env]